import request from '@/config/axios'

export interface AgentVO {
  id: number
  agentNumber: string
  telephone: string
  password: string
  groupId: number
  ownerUserId: number
}

// 查询坐席分页
export const getAgentPage = async (params) => {
  return await request.get({ url: `/call/agent/page`, params })
}
// 超管查询坐席分页
export const getAgentPageAdmin = async (params) => {
  return await request.get({ url: `/call/agent/page-by-admin`, params })
}
// 查询坐席详情
export const getAgent = async (id: number) => {
  return await request.get({ url: `/call/agent/get?id=` + id })
}
// 超管查询坐席详情
export const getAgentAdmin = async (params) => {
  return await request.get({ url: `/call/agent/get-by-admin`, params })
}
// 新增坐席
export const createAgent = async (data: AgentVO) => {
  return await request.post({ url: `/call/agent/create`, data })
}
// 超管新增坐席
export const createAgentAdmin = async (data: AgentVO) => {
  return await request.post({ url: `/call/agent/create-by-admin`, data })
}
// 修改坐席
export const updateAgent = async (data: AgentVO) => {
  return await request.put({ url: `/call/agent/update`, data })
}
// 超管修改坐席
export const updateAgentAdmin = async (data: AgentVO) => {
  return await request.put({ url: `/call/agent/update-by-admin`, data })
}
// 删除坐席
export const deleteAgent = async (id: number) => {
  return await request.delete({ url: `/call/agent/delete?id=` + id })
}
// 超管删除坐席
export const deleteAgentAdmin = async (val) => {
  return await request.delete({
    url: `/call/agent/delete-by-admin?id=${val.id}&tenantId=${val.tenantId}`
  })
}
// 导出坐席 Excel
export const exportAgent = async (params) => {
  return await request.download({ url: `/call/agent/export-excel`, params })
}

// 检查外呼渠道是否可用
export const getChannelId = async (params) => {
  return await request.get({ url: `/call/agent/get-channel`, params })
}

// 获取okcc账户加密信息：仅okcc需要
export const getAccountInfo = async (params) => {
  return await request.get({ url: `/call/agent/get-account-info`, params })
}

// 坐席操作
export const handleAgent = async (data) => {
  return await request.post({ url: `/call/agent/handle-agent`, data })
}
// 坐席点呼
export const simpleCall = async (data) => {
  return await request.post({ url: `/call/agent/simple-call`, data })
}
// 映射callId和reqNo
export const mapCallId = async (data) => {
  return await request.post({ url: `/call/agent/map-call-id`, data })
}

// 获取客户信息
export const getCustomerInfo = async (params) => {
  return await request.get({ url: `/call/agent/get-customer-info`, params })
}

// 跟进
export const addFollowRecord = async (data) => {
  return await request.post({ url: `/call/agent/add-follow-record`, data })
}

// 获取外呼任务的执行号码
export const getTaskNextNumber = async (mode, taskId) => {
  return await request.get({ url: `/call/task/get-next-number?mode=${mode}&taskId=${taskId}` })
}

// 根据会话No 查询话单
export const getRecordByReqNo = async (reqNo) => {
  return await request.get({ url: `/call/agent/get-call-by-no?reqNo=${reqNo}` })
}

// 电话失败成功调用
export const updateAgentStatus = async (data) => {
  return await request.post({ url: `/call/agent/update-agent-status`, data })
}

// 批量操作坐席（加白、修改主叫、修改有效期）
export const batchUpdateByAdmin = async (data) => {
  return await request.put({ url: `/call/agent/batch-update-by-admin`, data })
}

// 超管购买话费
export const buyUserBill = async (data) => {
  return await request.post({ url: `/system/tenant/buy-user-bill`, data })
}

// 查询套餐余额
export const tenantProductPage = async (params) => {
  return await request.get({ url: `/system/tenant-product/page`, params })
}
// 超管查询套餐余额
export const tenantProductPageAdmin = async (params) => {
  return await request.get({ url: `/system/tenant-product/page-by-admin`, params })
}
// 班组列表
export const groupSimple = async () => {
  return await request.get({ url: `/call/group/simple-list` })
}
// 获取当前登录用户坐席
export const agentInfo = async () => {
  return await request.get({ url: `/call/agent/info` })
}
// 创建群呼话费
export const batchCallM = async (data) => {
  return await request.post({ url: `/system/tenant/buy-tenant-bill`, data })
}
// 坐席班组
export const skillSimple = async () => {
  return await request.get({ url: `/call/group/skill-list` })
}
